<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!-- filter content -->
				<div class="row-fluid">
					<div class="span4">
						<span class="label label-info">开服日期：</span>
						<input value="${openTime }" id="openTime" type="text" class="Wdate" name="openTime" onFocus="WdatePicker({dateFmt:'yyyy-MM-dd',readOnly:true})">
					</div>
					<div class="span4">
							<span class="label label-info">审核状态：</span>
							<select id="status">
							      <option value="">全部</option>
							      <option value="01">未审核</option>
							      <option value="02">已审核</option>
      						</select>
      				</div>
      				
      				<div class="span4">
      					<span class="label label-info">标签：</span>
      						<select id="tag_filter">
      							<option value="">全部</option>
      							<c:forEach items="${tagList }" var="tag" begin="0" end="3">
      								<option value="${tag.id }">${tag.name }</option>
      							</c:forEach>
      						</select>
      				</div>
      				
      				<!-- <div class="span3">
      						<span class="label label-info">分页：</span>
      						<select id="pageSize">
					    		<option value="10">10</option>
					    		<option value="20">20</option>
					    		<option value="50">50</option>
					    		<option value="100">100</option>
      						</select>
      				</div> -->
      				<div >
      					<button id="query_btn" class="btn btn-primary" data-loading-text="Loading...">查询</button>
      				</div>
				</div>
<!-- filter content -->
			
			<!-- content grid -->
			<table class="table table-condensed table-bordered table-hover" >

					<tr>
						<th><input type="checkbox" name="checkAll" onclick="checkAll();"></th>
						<th>标题</th>
						<th>主页</th>
						<th>状态</th>
						<th>标签</th>
						<th>开服日期</th>
						<th>广告期限</th>
						<th>客服qq</th>
						<th>
							<button id="add_btn" class="btn btn-small btn-primary" onclick="add('content')">添加</button>
							<button id="del_btn" class="btn btn-small btn-primary" onclick="del('content');">删除</button>
						</th>
					</tr>
					<c:forEach items="${pageModel.list }" var="c">
						<tr dataid=${c.id }>
							<td align="center" width="20"><input type="checkbox" name="ck" onclick="checkOne();"></td>
							<td>${c.title}</td>
							<td>${c.site}</td>
							<td>${c.statusName }</td>
							<td>${c.tag.name }</td>
							<td>${c.openTime}</td>
							<td>${c.deadline}</td>
							<td>${c.qq}</td>
							<td>
								<button class="btn btn-small" onclick="edit('content',${c.id})">修改</button>
							</td>
						</tr>
					</c:forEach>
				</table>
			<!-- content grid -->
			
			<div class="btn-toolbar">
				<div class="btn-group">
					<a class="btn dropdown-toggle" data-toggle="dropdown" href="javascript:void(0)" id="tag_btn">
					   	打标签
					    <span class="caret"></span>
					  </a>
					  <ul class="dropdown-menu">
					  	<c:forEach items="${tagList }" var="tag" begin="0" end="3">
					  			<li onclick="tagContent(${tag.id});"><a href="javascript:void(0)" >${tag.name }</a></li>
      					</c:forEach>
					  </ul>
					<a class="btn btn-primary" id="deadline_btn">广告期限</a>
				</div>
				<div class="btn-group">
					<button id="approve_btn" class="btn btn-primary">审核</button>
				</div>
			</div>


<div id="deadlineModal" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
  <div class="modal-header">
    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
    <h3 id="myModalLabel">设置广告期限</h3>
  </div>
  <div class="modal-body">
    <p>
    	从<input type="text" placeholder="" class="input Wdate" id="dlStart" onFocus="WdatePicker({dateFmt:'yyyy-MM-dd',readOnly:true})">
    	到<input  type="text" placeholder="" class="input Wdate" id="dlEnd" onFocus="WdatePicker({dateFmt:'yyyy-MM-dd',readOnly:true})">
    </p>
  </div>
  <div class="modal-footer">
    <button class="btn" data-dismiss="modal" aria-hidden="true">关闭</button>
    <button class="btn btn-primary" id="deadline_btn_yes">确定</button>
  </div>
</div>

<script type="text/javascript">
   $(document).ready(function() {
	   $("#status").val('${status}');
	   $("#tag_filter").val('${tag}');
	  //审核
	   	$("#approve_btn").click(function(){
	   		var ids=getIds();
	   		if(ids==null){
	   			alert("请选择");
	   		}else if(confirm("确认要通过审核？")){
		   		$.post("/content/approve",{ids:ids},function(){
		   			showGrid();
		   		});
	   		}
	   		
	   	});
	  
	  //分类
	   	$("#tag_btn").click(function(){
	   		var ids=getIds();
	   		if(ids==null){
	   			alert("请选择");
	   		}else{
	   			$("#tag").val("");
	   		}
	   	});
	  
	  //查询
	   	$("#query_btn").click(function(){
	   		showGrid();
	   	});
	   	
	  //广告期限
	   	$("#deadline_btn").click(function(){
	   		var ids=getIds();
	   		if(ids==null){
	   			alert("请选择");
	   		}else{
	   			$('#deadlineModal').modal('show');
	   			$("#dlStart").val("");
	   			$("#dlEnd").val("");
	   		}
	   	});
	   	$('#deadline_btn_yes').click(function(){
	   		var ids=getIds();
	   		var deadline=$("#dlStart").val()+"至"+$("#dlEnd").val();
	   		$.post("/content/deadline",{ids:ids,deadline:deadline},function(){
	   			$('#deadlineModal').modal('hide');
	   			showGrid();
	   		});
	   	});
   });
   
   //打标签
   function tagContent(tag){
		var ids=getIds();
		$.post("/content/tag",{ids:ids,tag:tag},function(){
			showGrid();
		});
	}
   

   
   function showGrid(){
	   //JSONArray tagJson=JSONArray.fromObject(${tagList}); 
	   //$('#div_right').load("/content/manage");
		  $("#div_right").load("/content/manage",{
	  		  openTime:$("#openTime").val(),
	  		  status:$("#status").val(),
	  		  pageSize:$("#pageSize").val(),
	  		  tag:$("#tag_filter").val()
	  		  //tagJson:tagJson
	  	  });
	   }
</script>
